package controller;

import entity.Customer;
import entity.Staff;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.StaffService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/staff")
public class StaffCon {
    @Resource(name="staffService")
    private StaffService staffService;

    @RequestMapping("/listjin")
    @ResponseBody
    public List<Staff> listjin(){
        return staffService.listjin();
    }


    @RequestMapping("/listchu")
    @ResponseBody
    public List<Staff> listchu(){
        return staffService.listchu();
    }


    @RequestMapping("/Q")
    @ResponseBody
    public List<Staff> Q(){
        return staffService.Q();
    }


    @RequestMapping("/Qtiaozhuan")
    public String tiaozhuan(Model model) {
        return "WEB-INF/jsp/xitongshezhi/yuangongshezhi";
    }
    @RequestMapping("/Qtianjia")
    @ResponseBody
    public List<Staff> add2(Staff staff){
        Staff  staff1=new Staff();

        int s=staffService.Qadd(staff);

        return staffService.Q();

    }
    @RequestMapping("/Qxiugai")
    @ResponseBody
    public List<Staff> Qupd(Staff staff){
        Customer customer=new Customer();
        int s=staffService.Qupd(staff);
        return  staffService.Q();
    }
    @RequestMapping("/Qdel")
    @ResponseBody
    public List<Staff> Qdel(Staff staff){
        Staff  staff1=new Staff();
        int s=staffService.Qdel(staff);
        return staffService.Q();

    }

    @RequestMapping("/Qlist")
    @ResponseBody
    public List<Staff> Qlist(String name){
        Staff staff1=new Staff();


        staff1.setName(name);
        Map<String, Object> mapResult = new HashMap<String, Object>();

        mapResult.put("name",name);
        List<Staff>  staff=staffService.Qlist(mapResult);
        return staff;

    }

}
